package com.zcase;

import com.zcase.cpu.Cpu;
import com.zcase.memory.Memory;
import com.zcase.usb.KeyBoard;
import com.zcase.usb.Mouse;
import com.zcase.usb.USB;

import java.util.List;

public class Computer {
    private Cpu cpu;
    private List<Memory> memoryList;

    public Cpu getcpu(){
        return cpu;
    }

    public void setcpu(Cpu cpu){
        this.cpu = cpu;
    }

    public List<Memory> getMemoryList() {
        return memoryList;
    }

    public void setMemoryList(List<Memory> memoryList) {
        this.memoryList = memoryList;
    }
    public Computer(){
    }

    public Computer(Cpu cpu,List<Memory> memoryList) {
        this.cpu = cpu;
        this.memoryList = memoryList;
    }
    public void startRun(){
        cpu.calculate();
        for (Memory memory : memoryList) {
            memory.storage();
        }
    }

    public void installUSB(USB usb) {
        usb.connect();
        if (usb instanceof Mouse) {
            Mouse mouse = (Mouse) usb;
            mouse.click();
        } else if (usb instanceof KeyBoard) {
            KeyBoard keyBoard = (KeyBoard) usb;
            keyBoard.keyDown();
        }
    }
}
